package server;

import dao.ReletDao;
import pojo.OrderDto;

public class ReletServer {
	
	public OrderDto reletRoom(String roomNum,String preDay){
		
		ReletDao reletDao = new ReletDao();
		String money = reletDao.selectMoney(roomNum);
		System.out.println("money"+money);
		String orderId = reletDao.selectOrderId(roomNum);
		System.out.println("orderId"+orderId);
		OrderDto order = reletDao.selectOrder(orderId);
		System.out.println("order.prepay" + order.prePay);
		int sum = Integer.parseInt(money) * Integer.parseInt(preDay);
		int prepay = Integer.parseInt(order.prePay) +sum;
		int total = Integer.parseInt(order.total)+sum;
		
		order.nowPaid = Integer.toString(sum);
		order.prePay = Integer.toString(prepay);
		order.total = Integer.toString(total);
		order.orderId = orderId;
		order.roomNum = roomNum;
		order.preDay = preDay;
		
		reletDao.updateOrder(order);
		return order;
	}
}
